Fix GitLab fetch failing on GITLAB_HOST mismatch#215
Open
dhilgaertner wants to merge 1 commit intomainfrom
Open
Fix GitLab fetch failing on GITLAB_HOST mismatch#215dhilgaertner wants to merge 1 commit intomainfrom
dhilgaertner wants to merge 1 commit intomainfrom
Conversation
glab refuses to start when invoked from a git repo whose remote doesn't
correspond to GITLAB_HOST ("None of the git remotes configured for this
repository correspond to the GITLAB_HOST environment variable"). The
Crow app's inherited CWD is typically a GitHub repo, so every glab call
aborted and the entire GitLab fetch failed — assigned GitLab issues
never rendered.
Add an optional `cwd:` parameter to the shell helpers in IssueTracker
and ProviderManager, and pass NSHomeDirectory() at the four glab call
sites (issue list, api reconcile, mr view, issue view). HOME is not a
git repo, so glab's auto-detection finds no conflicting remotes.
Closes #195
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dgershman
approved these changes
Apr 25, 2026
Collaborator
dgershman
left a comment
There was a problem hiding this comment.
Code & Security Review
Critical Issues
None.
Security Review
Strengths:
- Uses
NSHomeDirectory()as the working directory — a safe, predictable path that avoids information leakage from arbitrary git repos - No new environment variable handling or user input flows introduced
- The
cwdparameter is optional with anildefault, preserving backward compatibility for non-glab callers
Concerns:
- None identified. The change is narrowly scoped to process working directory control.
Code Quality
- The fix is consistent across both files:
IssueTracker.swift(3 call sites + 2 shell helper signatures) andProviderManager.swift(2 call sites + 1 shell helper signature) - All
glabinvocations now passcwd: NSHomeDirectory()— no missed call sites - The
cwdparameter placement (betweenenv:and the variadic args) is clean and follows the existing parameter style - CrowProvider tests pass (25/25)
- Pre-existing (not this PR):
ProviderManager.shellcallswaitUntilExit()beforereadDataToEndOfFile()(L137-138), which can deadlock if output exceeds the 64 KB pipe buffer.IssueTracker.shellalready reads-then-waits (fixed in a prior PR). Worth a follow-up but not blocking.
Summary Table
| Priority | Issue |
|---|---|
| 🟢 Green | Pre-existing: ProviderManager.shell pipe read order (potential deadlock on large output) — follow-up item |
Recommendation: Approve — clean, minimal fix that solves the GITLAB_HOST mismatch by running glab from HOME instead of the app's inherited CWD. No security concerns, consistent implementation, tests pass.
dgershman
approved these changes
Apr 26, 2026
Collaborator
dgershman
left a comment
There was a problem hiding this comment.
Code & Security Review
Critical Issues
None.
Security Review
Strengths:
NSHomeDirectory()is a safe, deterministic directory choice — it exists on every macOS system and carries no secrets risk beyond what the user already has access to.- No new user-controlled input is introduced; the
cwdparameter is always called withNSHomeDirectory()(a constant) at every call site. - Environment variable handling (
GITLAB_HOST) is unchanged and correctly scoped.
Concerns:
- None identified.
Code Quality
Positive:
- Clean, minimal diff — adds the
cwd:parameter exactly where needed without over-engineering. - Both
IssueTrackerandProviderManagershell helpers are updated consistently with the same pattern (cwd: String? = nilwith default). - The
IssueTracker.shellcorrectly captureslet cwd = cwdfor theTask.detachedclosure, matching the existing pattern forargsandenv. - All four
glabcall sites are covered:fetchGitLabIssues,fetchGitLabMRsForReconcile, and bothglab mr view/glab issue viewinProviderManager.fetchTicket.
Pre-existing note (not introduced by this PR):
ProviderManager.shellcallswaitUntilExit()beforereadDataToEndOfFile()(lines 137–138). If aglabcommand produces >64 KB of output, this could deadlock. TheIssueTracker.shellalready reads pipes before waiting (and has a comment explaining why). This is pre-existing and low-risk forglabticket views, but worth noting for a future cleanup.
Summary Table
| Priority | Issue |
|---|---|
| Green | Pre-existing: ProviderManager.shell reads pipe after waitUntilExit — potential deadlock on large output (not introduced by this PR) |
Recommendation: Approve — the fix is correct, well-scoped, and the approach (running glab from $HOME to avoid git-remote auto-detection) is the right solution for the GITLAB_HOST mismatch problem. CrowProvider builds and all 25 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
glabrefused to run when Crow's inherited CWD was a git repo whose remote didn't matchGITLAB_HOST, abortingIssueTracker.fetchGitLabIssuesand three sibling glab calls.cwd:parameter to the shell helpers inIssueTrackerandProviderManager, and invokeglabfromNSHomeDirectory()so its auto-detection finds no conflicting remotes.Test plan
make build(clean)swift testfor top-level (31/31 passing) andCrowProviderpackage (25/25 passing)fetchGitLabIssues(host:) failed:log line no longer appears.Closes #195
🤖 Generated with Claude Code